package org.fireflow2.designer.eclipse.figures;

import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.PositionConstants;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;

public class TaskFigure extends Figure {
    public static Color color = new Color(null, 230, 230, 230);
    public static Color white = new Color(null, 255, 255, 255);
    private Label label;

	public TaskFigure(){
        this.label = new Label();
//        this.label.setTextAlignment(PositionConstants.LEFT);
        this.label.setLabelAlignment(PositionConstants.LEFT);

        this.add(label);      
        setOpaque(true);      
	}
	
    public String getText() {
        return this.label.getText();
    }

    public Rectangle getTextBounds() {
        return this.label.getTextBounds();
    }
    
    public void setText(String name) {
        this.label.setText(name);
        this.repaint();
    }	
    
    public void setImage(Image img){
    	this.label.setIcon(img);
    }
    
    public void setBounds(Rectangle rect) {
        super.setBounds(rect);
        this.label.setBounds(rect);
    }    
    
    public Dimension getPreferredSize(int wHint, int hHint){
    	Dimension d = new Dimension(wHint,20);
    	return d;
    }
    
    
    public void onFocused(){
    	this.setBackgroundColor(color);
    }
    
    public void onBlur(){
    	this.setBackgroundColor(white);
    }
    
//    public void handleFocusGained(FocusEvent event) {
//    	super.handleFocusGained(event);
//    	this.setBackgroundColor(color);
//    }
//
//    /**
//     * @see IFigure#handleFocusLost(FocusEvent)
//     */
//    public void handleFocusLost(FocusEvent event) {
//    	super.handleFocusLost(event);
//    	this.setBackgroundColor(white);
//    }    
}
